package exception01;
/*
* 手动处理异常
* */
public class ExceptionDemo02 {
    public static void main(String[] args) {
        int[] arr = new int[3];
        /*int i = method(arr, 2);
        System.out.println(i);  // 0*/

        int i = method(null, 1);
        System.out.println(i);
    }
    public static int method(int[] arr,int index){
        if(arr==null){
            return -1;       // -1
        }
        return arr[index];
    }
}

